import java.util.Arrays;

public class SortOddNEvenArray {

    public static int[] sortoe (int[] array) {
        int left = 0;
        int right = array.length - 1;
        while(left < right) {
            while(left < right && array[left] % 2 ==1 ) {
                left++;
            }
            while(left < right && array[right] % 2 == 0 ) {
                right--;
            }
            int temp = array[left];
            array[left] = array[right];
            array[right] = temp;
        }
        return array;
    }

    public static void main(String[] args) {
        int[] array = {1,8,4,3,6,2,3,4,7};
        System.out.println(Arrays.toString(sortoe(array)));
    }
}
